﻿using Prism.Commands;
using Prism.Mvvm;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using 基于WPF的电缆采样数据分析系统.Models.Enums;

namespace 基于WPF的电缆采样数据分析系统.ViewModels.TDRWork.OptionPage
{
    public class LangugeEditUCViewModel : BindableBase
    {

        // 单例模型
        public static LangugeEditUCViewModel Instance = new LangugeEditUCViewModel();

        #region 语言切换
        /// <summary>
        /// 语言切换命令
        /// </summary>
        public DelegateCommand<int?> LangugeChangedCmm { get; set; }

        /// <summary>
        /// 语言切换方法
        /// </summary>
        private void LangugeChangedFun(int? selectedIndex)
        {
            CurrentSelectedLanguge = (LangugeType)(selectedIndex);

            OptionUCViewModel.Instance.CurrentSelectedLanguge = CurrentSelectedLanguge;
            OptionUCViewModel.Instance.LangugeUpdate = (int)selectedIndex;
        }

        /// <summary>
        /// 当前语言
        /// </summary>
        private LangugeType _CurrentSelectedLanguge;

        /// <summary>
        /// 当前语言
        /// </summary>
        public LangugeType CurrentSelectedLanguge
        {
            get { return _CurrentSelectedLanguge; }
            set { 
                if (value == null)
                {
                    return;
                }
                _CurrentSelectedLanguge = value;
                RaisePropertyChanged();
            }
        }

        /// <summary>
        /// 当前语言下标值
        /// </summary>
        private int _CurrentSelectedIndex;

        /// <summary>
        /// 当前语言下标值
        /// </summary>
        public int CurrentSelectedIndex
        {
            get { return _CurrentSelectedIndex; }
            set { 
                _CurrentSelectedIndex = value;
                RaisePropertyChanged();
            }
        }


        #endregion

        /// <summary>
        /// 构造器
        /// </summary>
        public LangugeEditUCViewModel()
        {
            // 绑定语言切换命令
            LangugeChangedCmm = new DelegateCommand<int?>(LangugeChangedFun);

            CurrentSelectedIndex = OptionUCViewModel.Instance.CurrentSelectedLanguge == LangugeType.Chinese ? 0 : 1;

        }
    }
}
